log using kolfu_2017, replace


	preserve
	gen all =1
	matrix C =J(17, 5,.)	
	local i=0 
	local n=0
	
	foreach var in std_publicservice std_honesty_hum std_hrs_politics_res std_camp_sh {
	
			local n = `n'+1
			local p=-.3
				local i = `i'+1	
				local p= `p'+.15	
				areg `var' worker  a1-a5  woman if all==1 & led==1, abs(muni_party)
				matrix C[`i',1]=_b[worker]
				matrix C[`i',2]=(_b[worker]+1.96*_se[worker])
				matrix C[`i',3]=(_b[worker]-1.96*_se[worker])
				matrix C[`i',4]=`n'+`p'
				matrix C[`i',5]=`p'
				
		local i = `i'+1	
				local p= `p'+.15	
				areg `var' worker  a1-a5  woman i.party if all==1 & list_leader==1, abs(muni)
				matrix C[`i',1]=_b[worker]
				matrix C[`i',2]=(_b[worker]+1.96*_se[worker])
				matrix C[`i',3]=(_b[worker]-1.96*_se[worker])
				matrix C[`i',4]=`n'+`p'
				matrix C[`i',5]=`p'		
		
			
	}
		matrix list C
		svmat C
		sum C*
		rename C1 estimate
		rename C2 upper
		rename C3 lower
		rename C4 order
		
		tab C5
		gen var="led" if C5<.-1
		replace var="lead" if C5==0
	



 
  
twoway (rbar upper lower order if  var=="led", fcolor(black) lcolor(none) barwidth(.005)) ///
 (scatter estimate order if var=="led", mcolor(black) msize(large) msymbol(triangle)) ///
 (rbar upper lower order if var=="lead", fcolor(gs1) lcolor(gs1) barwidth(.005)) ///
 (scatter estimate order if var=="lead", mcolor(gs1) msize(large) msymbol(diamond)) , ///
 scheme(s1mono) ytitle(Gap between Workers and Non-Workers (SD)) yline(0, lpattern(dash) lcolor(gs7))  ///
 legend(order(2 "Municipal Councilor"  4  "Local Party Leader" ) row(2))  xlabel(1 "Public Service Motivation"  2 "Honesty-Humility" 3 "Hours Worked" 4 "Campaigning") ylabel(, angle(horizontal) grid)
 graph save Figure_7_left, replace
 restore



foreach var in s_leftright s_cutpublic {
preserve
	
collapse (mean) mean`var' = `var' (sd) sd`var' = `var' (count) n=`var', by(class)
generate hi`var' = mean`var'+invttail(n-1,0.025)*(sd`var' / sqrt(n))
generate low`var' = mean`var'-invttail(n-1,0.025)*(sd`var' / sqrt(n))

twoway (bar mean`var' class, barwidth(0.6) bcolor(gray)) ///
(rcap hi`var' low`var' class, lcolor(black)), ///
graphregion(color(white)) ylabel(, angle(0) gstyle(1)) xlab(, nogrid) yscale(range(-0.3 0.8)) ylabel(-0.2 0 0.2 0.4 0.6 0.8) ///
xtitle("") xsize(6) ysize(3) legend(off) scale(1.2) title(`var', size(medium))

graph save `var'worker.gph, replace
restore
}

* BAR GRAPH JOHANNA
graph combine s_leftrightworker.gph s_cutpublicworker.gph, ysize(7) xsize(5.5) col(1) graphregion(color(white))


* regressions



**********************************************************
* Table W1. Results for local politicians
**********************************************************

reg s_leftright i.class 
outreg2 using classpref, excel dec(2) replace
areg s_leftright i.class i.woman i.a4a i.edu3, abs(Kommun)
outreg2 using classpref, excel dec(2) append
areg s_leftright i.class i.woman i.a4a i.edu3 i.parti, abs(Kommun)
outreg2 using classpref, excel dec(2) append


reg s_cutpublic i.class 
outreg2 using classpref, excel dec(2) append
areg s_cutpublic i.class i.woman i.a4a i.edu3, abs(Kommun)
outreg2 using classpref, excel dec(2) append
areg s_cutpublic i.class i.woman i.a4a i.edu3 i.parti, abs(Kommun)
outreg2 using classpref, excel dec(2) append


log close
